package com.itheima.app.controller;

import com.itheima.app.manager.MakeFriendManager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;
import java.util.Map;

@RestController
public class BaiduController {

    @Autowired
    private MakeFriendManager makeFriendManager;

    /**
     * 上报地理位置
     * @param map 前台参数 包含经纬度和位置描述
     * @return null
     */
    @PostMapping("/baidu/location")
    public Map saveOrUpdateUserLocation(@RequestBody Map<String,String> map) {
        Double latitude = Double.valueOf(map.get("latitude"));
        Double longitude = Double.valueOf(map.get("longitude"));
        //System.out.println(latitude);
        //System.out.println(longitude);
        String  addrStr = map.get("addrStr");
        makeFriendManager.saveOrUpdateUserLocation(latitude, longitude, addrStr);
        return null;
    }


}
